import { ipcRenderer } from 'electron'

export function testIpc(){
  let message = ipcRenderer.sendSync("sync-message", "发个同步消息");
  console.log("同步消息:", message);

  //异步消息
  ipcRenderer.on("async-reply", (event, arg) => {
    console.log("异步消息:", arg);
  });

  ipcRenderer.send("async-message", "发个异步消息");
}

export async function ipcGetCommunityDetail(url,data){
  
  return new Promise(resolve=>{
    ipcRenderer.on("community-detail", (event, arg) => {
      let resData = JSON.parse(arg)
      resolve(resData);
    });
    
    ipcRenderer.send("community-detail", JSON.stringify([url,data]));
  })
}


